//    Openbravo POS is a point of sales application designed for touch screens.
//    Copyright (C) 2007-2009 Openbravo, S.L.
//    http://www.openbravo.com/product/pos
//
//    This file is part of Openbravo POS.
//
//    Openbravo POS is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    Openbravo POS is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with Openbravo POS.  If not, see <http://www.gnu.org/licenses/>.

package com.openbravo.pos.printer.escpos;

import javax.swing.JComponent;

import net.xeoh.plugins.base.annotations.PluginImplementation;

import com.openbravo.pos.config.ParametersConfig;
import com.openbravo.pos.printer.*;
import com.openbravo.pos.printer.config.ParametersComm;



@PluginImplementation
public  class DevicePrinterESCPOS extends AbstractDevicePrinterESCPOS{
      
	
	
    public DevicePrinterESCPOS() {
		super();
	}

	// Creates new TicketPrinter
    public DevicePrinterESCPOS(PrinterWritter CommOutputPrinter, Codes codes, UnicodeTranslator trans) throws TicketPrinterException {
        
        //m_sName = AppLocal.getIntString("Printer.Serial");
        m_CommOutputPrinter = CommOutputPrinter;
        m_codes = codes;
        m_trans = trans;

        // Inicializamos la impresora
        m_CommOutputPrinter.init(ESCPOS.INIT);

        m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER); // A la impresora
        m_CommOutputPrinter.init(m_codes.getInitSequence());
        m_CommOutputPrinter.write(m_trans.getCodeTable());

        m_CommOutputPrinter.flush();  
    }
    
    @Override
	public DevicePrinter init(String sPrinterParam1, String sPrinterParam2)
			throws TicketPrinterException {
    	 //m_sName = AppLocal.getIntString("Printer.Serial");
         m_CommOutputPrinter = PrinterWritterPool.INSTANCE.getPrinterWritter(sPrinterParam1, sPrinterParam2);
         return new DevicePrinterESCPOS(m_CommOutputPrinter,new CodesEpson(),new UnicodeTranslatorInt());
		
	}
   
    public JComponent getPrinterComponent() {
        return null;
    }
    @Override
	public String getPrinterType() {
		return "epson";
	}

	@Override
	public ParametersConfig getConfiguration() {
		return new ParametersComm();
	}

	
}

